from feffery_antd_components import AntdSelect
from typing import Any, Dict, List, Literal, Optional, Union
from uuid import uuid4
from utils.dict_util import DictManager


class ApiSelect(AntdSelect):
    def __init__(
        self,
        dict_type: str,
        id: Optional[Union[str, Dict]] = str(uuid4()),
        key: Optional[str] = None,
        style: Optional[Dict] = None,
        className: Optional[Union[str, Dict]] = None,
        popupClassName: Optional[str] = None,
        name: Optional[str] = None,
        locale: Optional[Literal['zh-cn', 'en-us', 'de-de']] = 'zh-cn',
        listHeight: Optional[Union[int, float]] = 256,
        colorsMode: Optional[Literal['sequential', 'diverging']] = 'sequential',
        colorsNameWidth: Optional[Union[int, float]] = 40,
        mode: Optional[Literal['multiple', 'tags']] = None,
        disabled: Optional[bool] = False,
        size: Optional[Literal['small', 'middle', 'large']] = 'middle',
        bordered: Optional[bool] = True,
        variant: Optional[Literal['outlined', 'borderless', 'filled']] = None,
        placeholder: Optional[str] = None,
        placement: Optional[
            Literal['bottomLeft', 'bottomRight', 'topLeft', 'topRight']
        ] = 'bottomLeft',
        value: Optional[Any] = None,
        defaultValue: Optional[Any] = None,
        maxTagCount: Optional[Union[int, float, Literal['responsive']]] = 5,
        status: Optional[Literal['error', 'warning']] = None,
        optionFilterProp: Optional[Literal['value', 'label']] = 'value',
        searchValue: Optional[str] = None,
        optionFilterMode: Optional[
            Literal[
                'case-insensitive', 'case-sensitive', 'regex', 'remote-match'
            ]
        ] = 'case-insensitive',
        debounceSearchValue: Optional[Any] = None,
        debounceWait: Optional[Union[int, float]] = 0,
        autoSpin: Optional[bool] = False,
        autoClearSearchValue: Optional[bool] = True,
        emptyContent: Optional[Any] = None,
        loadingEmptyContent: Optional[Any] = None,
        dropdownBefore: Optional[Any] = None,
        dropdownAfter: Optional[Any] = None,
        allowClear: Optional[bool] = True,
        autoFocus: Optional[bool] = False,
        popupMatchSelectWidth: Optional[bool] = True,
        readOnly: Optional[bool] = False,
        popupContainer: Optional[Literal['parent', 'body']] = 'body',
        batchPropsNames: Optional[List] = None,
        batchPropsValues: Optional[Dict] = None,
        loading_state: Optional[Any] = None,
        persistence: Optional[Any] = None,
        persisted_props: Optional[Any] = None,
        persistence_type: Optional[Any] = None,
        **kwargs: Any,
    ):
        self.options = DictManager.get_dict_options(dict_type=dict_type)[0]
        super().__init__(
            id=id,
            key=key,
            style=style,
            className=className,
            popupClassName=popupClassName,
            name=name,
            locale=locale,
            options=self.options,
            listHeight=listHeight,
            colorsMode=colorsMode,
            colorsNameWidth=colorsNameWidth,
            mode=mode,
            disabled=disabled,
            size=size,
            bordered=bordered,
            variant=variant,
            placeholder=placeholder,
            placement=placement,
            value=value,
            defaultValue=defaultValue,
            maxTagCount=maxTagCount,
            status=status,
            optionFilterProp=optionFilterProp,
            searchValue=searchValue,
            optionFilterMode=optionFilterMode,
            debounceSearchValue=debounceSearchValue,
            debounceWait=debounceWait,
            autoSpin=autoSpin,
            autoClearSearchValue=autoClearSearchValue,
            emptyContent=emptyContent,
            loadingEmptyContent=loadingEmptyContent,
            dropdownBefore=dropdownBefore,
            dropdownAfter=dropdownAfter,
            allowClear=allowClear,
            autoFocus=autoFocus,
            popupMatchSelectWidth=popupMatchSelectWidth,
            readOnly=readOnly,
            popupContainer=popupContainer,
            batchPropsNames=batchPropsNames,
            batchPropsValues=batchPropsValues,
            loading_state=loading_state,
            persistence=persistence,
            persisted_props=persisted_props,
            persistence_type=persistence_type,
            **kwargs,
        )
